package com.yang.servlet;

import com.yang.pojo.BasicInfo;
import com.yang.service.BasicInfoService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet("/BasicQueryServlet")
public class BasicQueryServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        BasicInfoService basicInfoService = new BasicInfoService();
        int basicInfoId = Integer.parseInt(request.getParameter("basicInfoId"));
        try {
            BasicInfo basicInfo = basicInfoService.findBasicInfoById(basicInfoId);
            request.setAttribute("basicInfo",basicInfo);
            request.getRequestDispatcher("basic_modify.jsp").forward(request,response);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request, response);
    }
}
